- any_issue_links = problems.any?{|e| e.issue_link.present? && e.issue_link != 'pending' }
=form_tag do
  %table.errs.selectable
    %thead
      %tr
        %th= check_box_tag "toggle_problems_checkboxes"
        %th= link_for_sort "App"
        %th= link_for_sort "What &amp; Where".html_safe, "message"
        %th= link_for_sort "Latest", "last_notice_at"
        %th= link_for_sort "Deploy", "last_deploy_at"
        %th= link_for_sort "Count"
        - if any_issue_links
          %th Issue
        %th Resolve
    %tbody
      - problems.each do |problem|
        %tr{:class => problem.resolved? ? 'resolved' : 'unresolved'}
          %td.select
            = check_box_tag "problems[]", problem.id, selected_problems.member?(problem.id.to_s)
          %td.app
            = link_to problem.app.name, app_path(problem.app)
            - if current_page?(:controller => 'problems')
              %span.environment= link_to problem.environment, problems_path(:environment => problem.environment)
            - else
              %span.environment= link_to problem.environment, app_path(problem.app, :environment => problem.environment)
          %td.message
            = link_to truncated_problem_message(problem), app_problem_path(problem.app, problem)
            %em= problem.where
            - if problem.comments_count > 0
              - comment = problem.comments.last
              %br
              .inline_comment
                - if comment.user
                  %em.commenter= (Errbit::Config.user_has_username ? comment.user.username : comment.user.email).to_s << ":"
                %em= truncate(comment.body, :length => 100, :separator => ' ')
          %td.latest #{time_ago_in_words(problem.last_notice_at)} ago
          %td.deploy= problem.last_deploy_at ? problem.last_deploy_at.to_s(:micro) : 'n/a'
          %td.count= link_to problem.notices_count, app_problem_path(problem.app, problem)
          - if any_issue_links
            %td.issue_link
              - if problem.app.issue_tracker_configured? && problem.issue_link.present? && problem.issue_link != 'pending'
                = link_to image_tag("#{problem.issue_type}_goto.png"), problem.issue_link, :target => "_blank"
          %td.resolve= link_to image_tag("thumbs-up.png"), resolve_app_problem_path(problem.app, problem),
            :title => "Resolve", :method => :put, :data => { :confirm => problem_confirm('resolve_one') },
            :class => 'resolve' if problem.unresolved?
      - if problems.none?
        %tr
          %td{:colspan => (any_issue_links ? 8 : 7)}
            %em No errs here
  = paginate problems
  .tab-bar
    %ul
      - %w(merge unmerge resolve unresolve delete).each do |action|
        %li= submit_tag action.capitalize, :id => "#{action}_problems", :class => 'button',
          :data => { :action => polymorphic_path([action == 'delete' ? 'destroy' : action, 'several_problems']),
          :confirm => problem_confirm(action) }
